package com.bree.erp.entity;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@NamedQueries({
	@NamedQuery(name = MasterItem.QUERY_SELECT_ALL_MASTERITEM,
			    query = "SELECT m FROM MasterItem m"),
	@NamedQuery(name = MasterItem.QUERY_FINDBYNAME_MASTERITEM,
			    query = "SELECT m FROM MasterItem m WHERE m.name = :name")
})
@Entity
public class MasterItem implements CrudId<Long> {
	
	private static final long serialVersionUID = 1L;
	
	public static final String QUERY_SELECT_ALL_MASTERITEM = "selectAllMasterItem";
	public static final String QUERY_FINDBYNAME_MASTERITEM = "findMasterItemByName";

	public static final int COL_NAME_LEN = 255;
	public static final int COL_DESCRIPTION_LEN = 255;
	public static final int COL_ITEMCODE_LEN = 25;

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	private Long id;
	
	@Column(length=COL_ITEMCODE_LEN)
	private String itemCode;
	
	@Column(length=COL_NAME_LEN)
	private String name;

	@Column(length=COL_DESCRIPTION_LEN)
	private String description;
	
	@ManyToOne
	private BrandSeller seller;
	
	@OneToMany(mappedBy="masterItem")
	private Collection<PartUnit> partUnits;


	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the seller
	 */
	public BrandSeller getSeller() {
		return seller;
	}

	/**
	 * @param seller the seller to set
	 */
	public void setSeller(BrandSeller seller) {
		this.seller = seller;
	}

	/**
	 * @return the partUnits
	 */
	public Collection<PartUnit> getPartUnits() {
		return partUnits;
	}

	/**
	 * @param partUnits the partUnits to set
	 */
	public void setPartUnits(Collection<PartUnit> partUnits) {
		this.partUnits = partUnits;
	}

	/**
	 * @return the itemCode
	 */
	public String getItemCode() {
		return itemCode;
	}

	/**
	 * @param itemCode the itemCode to set
	 */
	public void setItemCode(String itemCode) {
		this.itemCode = itemCode;
	}
	
}
